//
//  CalNewsTableViewCell.m
//  pocketNews
//
//  Created by DS on 2018/10/31.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "CalNewsTableViewCell.h"
@interface CalNewsTableViewCell()

Strong UIView * whiteView;

Strong UIImageView * picImageView;
Strong UILabel * titleLabel;
Strong UILabel * contentLabel;

@end

@implementation CalNewsTableViewCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    
    if (self = [super initWithCellIdentifier:cellID]) {
        
        _whiteView = [[UIView alloc] init];
        _whiteView.backgroundColor = getColor(whiteColor);
        
        _picImageView =[UIImageView addImgWithImage:@"geren_touxiang"];
        
        _titleLabel = [UILabel addLableFont:20 WithColor:getColor(@"111111")];
        
        //_titleLabel.text = @"uijkopopogjfkwelfkgjknflkgjnflkfgjnfgldkgfjn";
        _titleLabel.numberOfLines = 2;
        
        _contentLabel = [UILabel addLableFont:15 WithColor:getColor(@"696969")];
        //_contentLabel.text = @"567890-9876789076789678";
        _contentLabel.numberOfLines = 2;
        
        [self addSubview:self.whiteView];
        
        [self.whiteView sd_addSubviews:@[self.picImageView,self.titleLabel,self.contentLabel]];
        
        [self layOutFrame];
        
    }
    
    return self;
    
}

- (void)layOutFrame{
    ws(self)
    
    [self.whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(UNIT_HEIGHT(5));
        make.bottom.mas_equalTo(UNIT_HEIGHT(-5));
        make.left.mas_equalTo(UNIT_WIDTH(10));
        make.right.mas_equalTo(UNIT_WIDTH(-10));
    }];
    
    [self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(UNIT_HEIGHT(10));
        make.left.mas_equalTo(UNIT_WIDTH(10));
        make.bottom.mas_equalTo(UNIT_HEIGHT(-10));
        
       
        
        make.width.mas_equalTo(UNIT_HEIGHT(80));
        
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(UNIT_HEIGHT(10));
        make.left.mas_equalTo(weakself.picImageView.mas_right).offset(UNIT_WIDTH(10));
        make.right.mas_equalTo(UNIT_WIDTH(-10));
    }];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(UNIT_HEIGHT(-10));
       make.left.mas_equalTo(weakself.picImageView.mas_right).offset(UNIT_WIDTH(10));
         make.right.mas_equalTo(UNIT_WIDTH(-10));
    }];
    
    
}

- (void)setModel:(HomeSonModel *)model{
    
    
    _model = model;
    
    NSURL * url = [NSURL URLWithString:model.thumbnail_pic_s];
    
    [self.picImageView  sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"pic_32"]];
    
    self.titleLabel.text = model.title;
    
    self.contentLabel.text = model.author_name;
    
}


@end
